<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>监听子组件事件</title>
    <script src="../lib/vue-2.6.7.js"></script>
    <style type="text/css">
    </style>
</head>
<body>
<div id="app">
    <div :style="{ fontSize: postFontSize + 'em' } " >
        <blog-post
                v-on:enlarge-text="postFontSize += 0.1"
                v-for="post in posts"
                :key="post.id"
                :post-title="post.title"
        ></blog-post>
    </div>
</div>
<script>
    Vue.component('blog-post',{
        props: ['postTitle'],
        template: `<div id="blog"><h3>{{ postTitle }}</h3> <button  @click="$emit('enlarge-text')">点击放大</button></div>`
    });
    const vm = new Vue({
        el: "#app",
        data: {
            posts: [
                { id: 1, title: 'My journey with Vue' },
                { id: 2, title: 'Blogging with Vue' },
                { id: 3, title: 'Why Vue is so fun' }
            ],
            postFontSize:1
        }
    })
</script>
</body>
</html>